package org.lc.eic.messgeconstruct.requestreply;

import java.util.ArrayList;
import java.util.List;

public class History {
	
	private List<HistoryEntry> entries = new ArrayList<HistoryEntry>();
	
	public void addEntry(HistoryEntry entry){
		entries.add(entry);
	}
	
	public List<HistoryEntry> getEntries(){
		
		return new ArrayList<HistoryEntry>(entries);
	}
	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("History[");
		
		
		boolean first = true;
		
		for (HistoryEntry entry : entries) {
			
			if(first){
				first = false;
			} else{
				sb.append(", ");
			}
			sb.append("{timestamp=");
			sb.append(entry.getTimestamp());
			sb.append(", message=");
			sb.append(entry.getMessage());
			sb.append("}");
		}
		
		sb.append("]");
		return sb.toString();
	}

}
